package com.rockcent.mall.lib.repository;

import com.rockcent.mall.lib.domain.UploadFile;
import com.rockcent.mall.lib.domain.enumclass.FileKind;
import com.rockcent.mall.lib.domain.enumclass.FileStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by oyhk on 14-6-22.
 */
@Repository
public interface UploadFileRepository extends JpaRepository<UploadFile, Long>, JpaSpecificationExecutor {


    UploadFile findByEntityAndEntityIdAndKindAndStatus(String entity, Long entityId, FileKind fileKind, FileStatus fileStatus);
    UploadFile findTop1ByEntityAndEntityIdAndKindAndStatus(String entity, Long entityId, FileKind fileKind, FileStatus fileStatus);

    List<UploadFile> findByEntityAndEntityIdInAndKindAndStatus(String entity, List<Long> entityId, FileKind fileKind, FileStatus fileStatus);

    List<UploadFile> findByEntityAndEntityIdNot(String entity,Long entityId);

    List<UploadFile> findByEntityAndKindAndIdNot(String entity, FileKind fileKind, Long id);
}
